package com.sunplus.system.controller.system;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sunplus.common.annotation.Log;
import com.sunplus.common.constant.UserConstants;
import com.sunplus.common.core.controller.BaseController;
import com.sunplus.common.core.domain.AjaxResult;
import com.sunplus.common.core.domain.entity.SysRole;
import com.sunplus.common.core.domain.entity.SysUser;
import com.sunplus.common.core.domain.model.LoginUser;
import com.sunplus.common.core.page.TableDataInfo;
import com.sunplus.common.enums.BusinessType;
import com.sunplus.common.utils.SecurityUtils;
import com.sunplus.common.utils.ServletUtils;
import com.sunplus.common.utils.StringUtils;
import com.sunplus.common.utils.file.FileUtils;
import com.sunplus.common.utils.poi.ExcelUtil;
import com.sunplus.framework.web.service.TokenService;
import com.sunplus.system.service.ISysPostService;
import com.sunplus.system.service.ISysRoleService;
import com.sunplus.system.service.ISysUserService;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ResourceUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping({"/Admin", "/admin"})
public class AdminController extends BaseController {

    @Autowired
    private TokenService tokenService;

    /**
     * 菜单文件路径
     */
    @Value("${menu.location}")
    private String menuLocation;


    private JSONArray menuData(JSONArray menuArray) {
        Iterator<Object> o = menuArray.iterator();
        while (o.hasNext()) {
            JSONObject menu = (JSONObject) o.next();
            if ("button".equals(menu.getString("type"))) {
                o.remove();
            }
            if (menu.getJSONArray("list") != null) {
                menuData(menu.getJSONArray("list"));
            }
        }
        return menuArray;
    }

    @PostMapping("/getMenu")
    public AjaxResult getMenu() throws Exception {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        File jsonFile = ResourceUtils.getFile(menuLocation);
        String menu = FileUtils.readFileToString(jsonFile, "utf-8");

       /* String menu = "[{\"id\":\"1\",\"name\":null,\"type\":\"page\",\"icon\":\"layui-icon-home\"," +
                "\"title\":\"我的面板\",\"jump\":null,\"list\":[{\"id\":\"1-2\",\"name\":null,\"type\":\"page\",\"icon\":null,\"title\":\"修改密码\",\"jump\":\"/set/user/password\",\"list\":null,\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"1-2\",\"name\":\"homepage1\",\"type\":\"page\",\"icon\":null,\"title\":\"个人设置\",\"jump\":\"/set/user/info\",\"list\":null,\"spread\":false,\"site\":null,\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"2\",\"name\":\"base\",\"type\":\"page\",\"icon\":\"layui-icon-home\",\"title\":\"基础信息\",\"jump\":null,\"list\":[{\"id\":\"2-1\",\"name\":\"shop_store\",\"type\":\"page\",\"icon\":null,\"title\":\"店铺管理\",\"jump\":\"/shop/shop_store/index\",\"list\":[{\"id\":\"2-1-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"2-2\",\"name\":\"shop_supplier\",\"type\":\"page\",\"icon\":null,\"title\":\"供应商管理\",\"jump\":\"/shop/shop_supplier/index\",\"list\":[{\"id\":\"2-2-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"2-2-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"2-2-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"2-2-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"2-2-open\",\"name\":\"open\",\"type\":\"button\",\"icon\":null,\"title\":\"启用/停用\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"2-6\",\"name\":\"Portal_Article\",\"type\":\"page\",\"icon\":null,\"title\":\"文章管理\",\"jump\":\"/admin/Portal_Article/Index\",\"list\":[{\"id\":\"2-6-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"2-6-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"2-6-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"2-6-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"3\",\"name\":\"product\",\"type\":\"page\",\"icon\":\"layui-icon-cart-simple\",\"title\":\"商品管理\",\"jump\":null,\"list\":[{\"id\":\"3-1\",\"name\":\"shop_GoodsCategory\",\"type\":\"page\",\"icon\":null,\"title\":\"商品分类\",\"jump\":\"/shop/shop_GoodsCategory/index\",\"list\":[{\"id\":\"3-1-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-1-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"3-1-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"3-1-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"3-3\",\"name\":\"shop_goods_base\",\"type\":\"page\",\"icon\":null,\"title\":\"基础商品\",\"jump\":\"/shop/shop_goods_base/index\",\"list\":[{\"id\":\"3-3-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-3-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"3-3-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"3-3-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"3-3-audit\",\"name\":\"audit\",\"type\":\"button\",\"icon\":null,\"title\":\"审核\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-3-showon\",\"name\":\"showon\",\"type\":\"button\",\"icon\":null,\"title\":\"启用\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-3-showup\",\"name\":\"showup\",\"type\":\"button\",\"icon\":null,\"title\":\"停用\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-3-sync\",\"name\":\"sync\",\"type\":\"button\",\"icon\":null,\"title\":\"同步\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-3-storegood\",\"name\":\"storegood\",\"type\":\"button\",\"icon\":null,\"title\":\"店铺商品操作权限\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"3-5\",\"name\":\"shop_goods_base\",\"type\":\"page\",\"icon\":null,\"title\":\"商品池\",\"jump\":\"/shop/shop_goods_base/indexPond\",\"list\":[{\"id\":\"3-5-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"3-5-tostore\",\"name\":\"tostore\",\"type\":\"button\",\"icon\":null,\"title\":\"选品到店铺\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"3-4\",\"name\":\"shop_Goods\",\"type\":\"page\",\"icon\":null,\"title\":\"店铺商品\",\"jump\":\"/shop/shop_Goods/index\",\"list\":[{\"id\":\"3-4-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"3-4-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"3-4-setstock\",\"name\":\"setstock\",\"type\":\"button\",\"icon\":null,\"title\":\"设置库存\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-4-showon\",\"name\":\"showon\",\"type\":\"button\",\"icon\":null,\"title\":\"上架\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-4-showup\",\"name\":\"showup\",\"type\":\"button\",\"icon\":null,\"title\":\"下架\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"3-4-sales\",\"name\":\"sales\",\"type\":\"button\",\"icon\":null,\"title\":\"设置销量\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"8\",\"name\":\"right\",\"type\":\"page\",\"icon\":\"layui-icon-cart-simple\",\"title\":\"订单管理\",\"jump\":null,\"list\":[{\"id\":\"8-1\",\"name\":\"shop_Order\",\"type\":\"page\",\"icon\":null,\"title\":\"订单管理\",\"jump\":\"/shop/shop_Order/orderindex\",\"list\":[{\"id\":\"8-1-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"8-1-sendGoods\",\"name\":\"sendGoods\",\"type\":\"button\",\"icon\":null,\"title\":\"发货\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"8-1-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"8-1-deliver\",\"name\":\"deliver\",\"type\":\"button\",\"icon\":null,\"title\":\"发货\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"8-2\",\"name\":\"shop_Order\",\"type\":\"page\",\"icon\":null,\"title\":\"发货单管理\",\"jump\":\"/shop/shop_Order_Deliver/index\",\"list\":[{\"id\":\"8-2-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"8-3\",\"name\":\"shop_order_return\",\"type\":\"page\",\"icon\":null,\"title\":\"退款管理\",\"jump\":\"/shop/shop_order_return/index\",\"list\":[{\"id\":\"8-3-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"8-3-audit\",\"name\":\"audit\",\"type\":\"button\",\"icon\":null,\"title\":\"审核\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"8-5\",\"name\":\"shop_otherorder\",\"type\":\"page\",\"icon\":null,\"title\":\"第三方信息\",\"jump\":\"/shop/shop_otherorder/index\",\"list\":[{\"id\":\"8-5-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"8-6\",\"name\":\"shop_order_score\",\"type\":\"page\",\"icon\":null,\"title\":\"评价管理\",\"jump\":\"/shop/shop_order_score/index\",\"list\":[{\"id\":\"8-6-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"8-6-BAudit\",\"name\":\"BAudit\",\"type\":\"button\",\"icon\":null,\"title\":\"审核\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"8-6-lead\",\"name\":\"lead\",\"type\":\"button\",\"icon\":null,\"title\":\"导入\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"8-6-AAudit\",\"name\":\"AAudit\",\"type\":\"button\",\"icon\":null,\"title\":\"审核\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"8-6-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"4\",\"name\":null,\"type\":\"page\",\"icon\":\"layui-icon-senior\",\"title\":\"店铺设置\",\"jump\":null,\"list\":[{\"id\":\"4-2\",\"name\":\"homepage1\",\"type\":\"page\",\"icon\":null,\"title\":\"广告管理\",\"jump\":\"/shop/shop_Advertisement/Index\",\"list\":[{\"id\":\"4-2-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"4-2-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"4-2-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"4-5\",\"name\":\"homepage1\",\"type\":\"page\",\"icon\":null,\"title\":\"主题管理\",\"jump\":\"/shop/shop_Theme/Index\",\"list\":[{\"id\":\"4-5-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"4-5-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"4-5-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"4-5-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"4-6\",\"name\":\"homepage1\",\"type\":\"page\",\"icon\":null,\"title\":\"主题推荐\",\"jump\":\"/shop/shop_ThemeRecommend/Index\",\"list\":[{\"id\":\"4-6-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"4-6-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"4-6-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"4-6-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"4-7\",\"name\":\"homepage1\",\"type\":\"page\",\"icon\":null,\"title\":\"商品推荐\",\"jump\":\"/shop/shop_HomeRecommend/Index\",\"list\":[{\"id\":\"4-7-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up\",\"buttonStr\":null},{\"id\":\"4-7-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"4-7-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"4-7-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"6\",\"name\":null,\"type\":\"page\",\"icon\":\"layui-icon-senior\",\"title\":\"运营管理\",\"jump\":null,\"list\":[{\"id\":\"6-1\",\"name\":\"shop_coupon\",\"type\":\"page\",\"icon\":null,\"title\":\"优惠卷管理\",\"jump\":\"/shop/shop_coupon/Index\",\"list\":[{\"id\":\"6-1-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"6-1-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"6-1-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"6-1-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"5\",\"name\":\"right\",\"type\":\"page\",\"icon\":\"layui-icon-user\",\"title\":\"权限管理\",\"jump\":null,\"list\":[{\"id\":\"5-1\",\"name\":\"Portal_User\",\"type\":\"page\",\"icon\":null,\"title\":\"系统用户\",\"jump\":\"/admin/Portal_User/index\",\"list\":[{\"id\":\"5-1-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"5-1-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-1-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"5-1-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-1-SetRole\",\"name\":\"SetRole\",\"type\":\"button\",\"icon\":null,\"title\":\"角色\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-1-updatepassword\",\"name\":\"updatepassword\",\"type\":\"button\",\"icon\":null,\"title\":\"重置密码\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"5-8\",\"name\":\"Portal_User_Supplier\",\"type\":\"page\",\"icon\":null,\"title\":\"供应商用户\",\"jump\":\"/admin/Portal_User_Supplier/index\",\"list\":[{\"id\":\"5-8-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"5-8-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-8-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"5-8-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-8-SetRole\",\"name\":\"SetRole\",\"type\":\"button\",\"icon\":null,\"title\":\"角色\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-8-updatepassword\",\"name\":\"updatepassword\",\"type\":\"button\",\"icon\":null,\"title\":\"重置密码\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"5-2\",\"name\":\"Portal_Right_Role\",\"type\":\"page\",\"icon\":null,\"title\":\"角色管理\",\"jump\":\"/admin/Portal_Right_Role/index\",\"list\":[{\"id\":\"5-2-add\",\"name\":\"add\",\"type\":\"button\",\"icon\":null,\"title\":\"添加\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"5-2-edit\",\"name\":\"edit\",\"type\":\"button\",\"icon\":null,\"title\":\"编辑\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-2-del\",\"name\":\"del\",\"type\":\"button\",\"icon\":null,\"title\":\"删除\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"up|table\",\"buttonStr\":null},{\"id\":\"5-2-view\",\"name\":\"view\",\"type\":\"button\",\"icon\":null,\"title\":\"查看\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null},{\"id\":\"5-2-SetRight\",\"name\":\"SetRight\",\"type\":\"button\",\"icon\":null,\"title\":\"权限\",\"jump\":null,\"list\":null,\"spread\":false,\"site\":\"table\",\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null},{\"id\":\"5-6\",\"name\":\"Portal_Config\",\"type\":\"page\",\"icon\":null,\"title\":\"系统配置\",\"jump\":\"/admin/Portal_Config/SysConfig\",\"list\":null,\"spread\":false,\"site\":null,\"buttonStr\":null}],\"spread\":false,\"site\":null,\"buttonStr\":null}]";
        */

        return AjaxResult.success(menuData(JSONArray.parseArray(menu)));
    }

    @PostMapping({"/GetLoginUser", "/getLoginUser"})
    public AjaxResult getLoginUser() throws Exception {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
//        JSONObject user = new JSONObject();
//        user.put("Email", loginUser.getUser().getEmail());
//        user.put("GroupID", "6E0647FD-105B-41F6-929A-32BC9D1CF5F1");
//        user.put("IsDelete", loginUser.getUser().getDelFlag());
//        user.put("IsRegisterIM", 1);
//        user.put("LastLoginTime", loginUser.getUser().getLoginDate());
//        user.put("Mobile", loginUser.getUser().getPhonenumber());
//        user.put("PID", loginUser.getUser().getUserId());
//        user.put("PassWord", loginUser.getUser().getPassword());
//        user.put("Photo_Upload", loginUser.getUser().getAvatar());
//        user.put("Remark", null);
//        user.put("State_Sel", loginUser.getUser().getStatus());
//        user.put("StoreID", "");
//        user.put("SupplierID", null);
//        user.put("UpdateTime", "2020-10-14 10:43:13");
//        user.put("UpdateUser", "85ACDD49-56BA-40E6-B938-D8857F629F44");
//        user.put("UserID", loginUser.getUsername());
//        user.put("UserName", loginUser.getUser().getUserName());
//        user.put("UserType_Sel", loginUser.getUser().getUserType());
        return AjaxResult.success(JSON.parseObject(JSON.toJSONString(loginUser.getUser())));
    }

    @PostMapping("/getLoginGroupName")
    public AjaxResult getLoginGroupName() throws Exception {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        return AjaxResult.success("云端服务");
    }

}
